package com.yinshan.library;

import android.content.Context;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.View;
import android.widget.EditText;

import com.yinshan.dialog.NumKeyDialog;

import java.lang.ref.WeakReference;

public class MainActivity extends AppCompatActivity {
    private final String TAG = "MainActivity";
    private Context context;
    private EditText txtInput;
    private String sm2PublicKey = "c1badd7cff2f225ba0e9af96e015f4a93ca017b3c92f3700bb122662bfe9eb401de4a65848a27e4713d95b6dcdba821ea896feb300e18a3390075202ed72e068";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        context = new WeakReference<>(this).get();
        initViews();
    }

    private void initViews() {
        txtInput = findViewById(R.id.txt_input);
        findViewById(R.id.btn).setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                new NumKeyDialog.Builder(context).setNoHandle(false).setPhone("18229048982").setEncryptKeyboard(false, sm2PublicKey)
                        .setOnTextResultListener(new NumKeyDialog.Builder.OnTextResultListener() {
                            @Override
                            public void OnTextResult(NumKeyDialog.Builder builder, String result, int type) {
                                Log.d(TAG, "输入结果：" + result);
                                txtInput.setText(result);
                            }
                        })
                        .create().show();
            }
        });
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();

    }

}
